package com.atguigu.lease.common.exception;

import com.atguigu.lease.common.result.Result;
import com.atguigu.lease.common.result.ResultCodeEnum;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * ClassName: GlobalExceptionHandlers
 * Package: com.atguigu.lease.common.exception
 * Description:
 *
 * @author: fu-wang
 * @create: 2024/10/1 17:51
 * version: 1.0
 */
@RestControllerAdvice
public class GlobalExceptionHandlers {

    @ExceptionHandler({LeaseException.class})
    public Result leaseExceptionHandler(LeaseException e){
        e.printStackTrace();
       ResultCodeEnum resultCodeEnum = e.getResultCodeEnum();
       return Result.build(null,resultCodeEnum);
    }

    @ExceptionHandler(Exception.class)
    public Result exception(Exception e){
        e.printStackTrace();
        return Result.fail();
    }
}
